<include file="./Application/User/View/Header/header.html" />
<section>
    <script type="text/javascript">
        function save(){

            $.ajax({
                url: '{:U("/User/Activity/save?type=4")}',
                type: 'post',
                data: $("#From").serialize(),
            })
                    .done(function(data) {
                        console.log(data);
                        alert(data);
                    })
                    .fail(function() {
                        console.log("error");
                    })
                    .always(function() {
                        console.log("complete");
                    });

        }

        function test(){
            $("#From").submit();

        }
    </script>
    <form id="From" action='{:U("/User/Activity/save?type=1")}' method="post" class="am-form am-form-horizontal">
        <div class="am-container">
            <div class="am-panel-group" id="accordion">

                <div class="am-panel am-panel-primary">
                    <div class="am-panel-hd">
                        <h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#do-not-say-2'}">
                            活动准备
                        </h4>
                    </div>
                    <div id="do-not-say-2" class="am-panel-collapse am-collapse am-in">
                        <div class="am-panel-bd">

                            <table class="am-table am-table-bd am-table-bdrs am-table-striped">
                                <thead>
                                <tr>
                                    <th width="10%">序号</th>
                                    <th width="15%">准备时间</th>
                                    <th>准备内容</th></tr>
                                </thead>
                                <tbody id="activity_tbody">

                                <for start="0" end="$prepareNum">
                                    <tr>
                                        <td>{$i+1}</td>
                                        <input type="hidden" name="prid[]" value="{$prepare[$i].prid}">
                                        <td> <input type="text" name="prtime[]" class="am-form-field datepicker" placeholder="准备时间" value="{$prepare[$i].prtime}"></td>
                                        <td><input type="text" name="prcontent[]" class="am-form-field" placeholder="准备内容" value="{$prepare[$i].prcontent}"></td>
                                    </tr>
                                </for>

                                </tbody>
                            </table>

                            <div class="am-form-group">
                                <button type="button" class="am-btn am-btn-default" onclick="add_activity_tbody()">继续添加</button>
                            </div>


                        </div>
                    </div>
                </div>
                <div class="am-panel am-panel-primary">
                    <div class="am-panel-hd">
                        <h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#do-not-say-1'}">
                            活动情况
                        </h4>
                    </div>
                    <div id="do-not-say-1" class=" am-panel-collapse am-collapse">
                        <div class="am-panel-bd">
                            <!-- <form class="am-form am-form-horizontal">  -->
                            <input type="hidden" name="aid" value="{$activity.aid}">

                            <div class="am-form-group">
                                <label for="doc-ipt-3" class="col-sm-2 am-form-label">活动主题</label>
                                <div class="col-sm-10">
                                    <input type="text" name="atheme" value="{$activity.atheme}" id="doc-ipt-3" placeholder="活动主题..">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="col-sm-2 am-form-label">活动时间</label>
                                <div class="col-sm-10">
                                    <input type="text" name="atime" class="am-form-field datepicker" placeholder="准备时间" value="{$activity.atime}">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="col-sm-2 am-form-label">活动参与人数</label>
                                <div class="col-sm-10">
                                    <input type="text" name="astunumber" value="{$activity.astunumber}" placeholder="8">
                                </div>
                            </div>



                            <div class="am-form-group">
                                <label  class="col-sm-2 am-form-label">活动新闻</label>
                                <div class="col-sm-10">
                                    <textarea name="anews"class="" rows="5" id="doc-ta-1">{$activity.anews}</textarea>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label  class="col-sm-2 am-form-label">活动感受</label>
                                <div class="col-sm-10">
                                    <textarea name="aexperience"class="" rows="5" id="doc-ta-1">{$activity.aexperience}</textarea>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label  class="col-sm-2 am-form-label">活动类型</label>
                                <div class="col-sm-10">
                                    <select id="atype" name="atype">
                                        <option value="1">选项一...</option>
                                        <option value="2">选项二.....</option>
                                        <option value="3">选项三........</option>
                                    </select>
                                </div>
                                <span class="am-form-caret"></span>
                            </div>
                            <div class="am-form-group">

                            </div>
                            <!-- </form>  -->

                        </div>
                    </div>
                </div>
                <div class="am-panel am-panel-primary">
                    <div class="am-panel-hd">
                        <h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#do-not-say-3'}">费用记录</h4>
                    </div>
                    <div id="do-not-say-3" class="am-panel-collapse am-collapse">
                        <div class="am-panel-bd">
                            <table class="am-table am-table-bd am-table-bdrs am-table-striped">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>费用类别</th>
                                    <th>费用明细</th>
                                    <th>费用用途</th>
                                    <th>费用金额</th></tr>
                                </thead>
                                <tbody id="cost_tbody">
                                <for start="0" end="$costNum">
                                    <tr>
                                        <td>{$i+1}
                                            <input type="hidden" name="cid[]" value="{$cost[$i].cid}">
                                        </td>
                                        <td><select id="ccategory{$i+1}" name="ccategory[]">
                                            <option value="0"></option>
                                            <option value="1">办公用品</option>
                                            <option value="2">耗材</option>
                                            <option value="3">图书费</option>
                                            <option value="4">出租费</option>
                                            <option value="5">停车费</option>
                                            <option value="6">汽油费</option>
                                            <option value="7">餐费</option>
                                            <option value="8">复印费</option>
                                            <option value="9">网费</option>
                                            <option value="10">电话费</option>
                                            <option value="11">其它</option>
                                        </select><span class="am-form-caret"></span></td>
                                        <td><input type="" class="am-form-field" placeholder="费用明细" value="{$cost[$i].ccontent}"  name="ccontent[]"></td>
                                        <td><input type="" class="am-form-field" placeholder="费用用途" value="{$cost[$i].cactual}" name="cactual[]"></td>
                                        <td><input type="" class="am-form-field" placeholder="费用金额" value="{$cost[$i].cost}" name="cost[]"></td>
                                    </tr>
                                </for>
                                </tbody>
                            </table>




                            <div class="am-form-group">
                                <button type="button" class="am-btn am-btn-default" onclick="add_cost_tbody()">继续添加</button>

                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </form>
    <div class="am-container"><button type="button" class="am-btn am-btn-primary am-align-right" onclick="test()">提交</button>
        <button type="button" class="am-btn am-btn-default am-align-right" onclick="save()">保存</button></div>


</section>


<include file="./Application/User/View/Footer/footer.html" />
<link rel="stylesheet" href="__PUBLIC__/assets/css/jquery-ui.min.css">
<script src="__PUBLIC__/assets/js/jquery.js"></script>
<script src="__PUBLIC__/assets/js/jquery-ui.min.js"></script>
<script type="text/javascript">
    function add_cost_tbody(){
        var num=$("#cost_tbody").children("tr").length+1;
        $("#cost_tbody").append("<tr><td>"+num+"</td><td><input type='hidden' name='cid[]'><select id='ccategory"+num+"'  name='ccategory[]'><option value='1'>办公用品</option><option value='2'>耗材</option><option value='3'>图书费</option><option value='4'>出租费</option><option value='5'>停车费</option><option value='6'>汽油费</option><option value='7'>餐费</option><option value='8'>复印费</option><option value='9'>网费</option><option value='10'>电话费</option><option value='11'>其它</option></select><td><input class='am-form-field' placeholder='费用明细' name='ccontent[]'></td><td><input class='am-form-field' placeholder='费用用途' name='cactual[]'></td><td><input class='am-form-field' placeholder='费用金额' name='cost[]'></td></tr>")

    }
    function add_activity_tbody(){
        var num=$("#activity_tbody").children("tr").length+1;
        $("#activity_tbody").append("<tr><td>"+num+"</td><td><input type='hidden' name='prid[]'><input type='text' name='prtime[]' class='am-form-field datepicker' placeholder='准备时间'></td><td><input  type='text' name='prcontent[]' class='am-form-field' placeholder='准备内容'></td></tr>")
        $( ".datepicker" ).datepicker( { dateFormat: "yy-mm-dd" });
    }
    $(function() {
        $( ".datepicker" ).datepicker({ dateFormat: "yy-mm-dd" });
        var num = {$costNum}+1;
        var cost = <?=json_encode($cost)?>;


        $("#atype").val({$activity.atype});
    for(j=1;j<num;j++) {
        //alert(cost[j-1].ccategory);
        // console.log(cost);
        $("#ccategory"+j).val(cost[j-1].ccategory);
    }
    });


</script>